import 'package:flutter/material.dart';

// 左右线性渐变色
const gridient = LinearGradient(colors: [
  Color(0xffF85238),
  Color(0xFFE2112C),
]);

class Home extends StatefulWidget {
  @override
  _Home createState() => _Home();
}

class _Home extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        title: Text('华林CRM'),
        flexibleSpace: Container(
          decoration: BoxDecoration(
            gradient: gridient,
          ),
        ),
      ),
      body: ListView(
        children: <Widget>[
          Stack(
            overflow: Overflow.visible,
            children: <Widget>[
              ClipPath(
                clipper: MyClipper(),
                child: Container(
                  width: double.infinity,
                  height: 120,
                  decoration: BoxDecoration(gradient: gridient),
                ),
              ),
              Padding(
                padding: EdgeInsets.only(top: 8, left: 10, right: 10),
                child: Container(
                  width: double.infinity,
                  height: 140,
                  decoration: BoxDecoration(
                    color: Colors.blue,
                    borderRadius: BorderRadius.all(Radius.circular(8)),
                  ),
                ),
              )
            ],
          ),
          Text(
            'LIST VIEW',
            style: TextStyle(
              color: Colors.red,
            ),
          )
        ],
      ),
    );
  }
}

class MyClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var path = Path();
    path.lineTo(0, size.height - 80);
    path.quadraticBezierTo(
        size.width / 2, size.height, size.width, size.height - 80);
    path.lineTo(size.width, 0);
    path.close();
    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return false;
  }
}
